]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
layout: deal better with vertically-stacked monitors
authorDan Winship <danw@gnome.org>
Mon, 13 Jun 2011 14:37:10 +0000 (10:37 -0400)
committerDan Winship <danw@gnome.org>
Wed, 6 Jul 2011 12:38:35 +0000 (08:38 -0400)
If there is a monitor below the primary monitor, then put the message
tray there, rather than necessarily on the primary.

https://bugzilla.gnome.org/show_bug.cgi?id=636963

js/ui/layout.js
js/ui/messageTray.js

index 0fd0eb596b4f30b97f5e88b10f7534638520d9bc..37a8bb7bfcfb79ef22ae3f4d71671049270cd479 100644 (file)
@@ -38,8 +38,22 @@ LayoutManager.prototype = {
         for (let i = 0; i < nMonitors; i++)
             this.monitors.push(screen.get_monitor_geometry(i));
 
-        this.primaryIndex = screen.get_primary_monitor();
+        if (nMonitors == 1) {
+            this.primaryIndex = this.bottomIndex = 0;
+        } else {
+            // If there are monitors below the primary, then we need
+            // to split primary from bottom.
+            this.primaryIndex = this.bottomIndex = screen.get_primary_monitor();
+            for (let i = 0; i < this.monitors.length; i++) {
+                let monitor = this.monitors[i];
+                if (this._isAboveOrBelowPrimary(monitor)) {
+                    if (monitor.y > this.monitors[this.bottomIndex].y)
+                        this.bottomIndex = i;
+                }
+            }
+        }
         this.primaryMonitor = this.monitors[this.primaryIndex];
+        this.bottomMonitor = this.monitors[this.bottomIndex];
     },
 
     _updateHotCorners: function() {
@@ -103,6 +117,20 @@ LayoutManager.prototype = {
         this.emit('monitors-changed');
     },
 
+    _isAboveOrBelowPrimary: function(monitor) {
+        let primary = this.monitors[this.primaryIndex];
+        let monitorLeft = monitor.x, monitorRight = monitor.x + monitor.width;
+        let primaryLeft = primary.x, primaryRight = primary.x + primary.width;
+
+        if ((monitorLeft >= primaryLeft && monitorLeft <= primaryRight) ||
+            (monitorRight >= primaryLeft && monitorRight <= primaryRight) ||
+            (primaryLeft >= monitorLeft && primaryLeft <= monitorRight) ||
+            (primaryRight >= monitorLeft && primaryRight <= monitorRight))
+            return true;
+
+        return false;
+    },
+
     get focusIndex() {
         let screen = global.screen;
         let display = screen.get_display();
index a1b99bf61d5d057276740333c2571325819df817..e6be84c6b55b680e1b3c47e3689f3eb2ce392247 100644 (file)
@@ -1293,20 +1293,20 @@ MessageTray.prototype = {
     },
 
     _setSizePosition: function() {
-        let primary = Main.layoutManager.primaryMonitor;
-        this.actor.x = primary.x;
-        this.actor.y = primary.y + primary.height - 1;
-        this.actor.width = primary.width;
+        let monitor = Main.layoutManager.bottomMonitor;
+        this.actor.x = monitor.x;
+        this.actor.y = monitor.y + monitor.height - 1;
+        this.actor.width = monitor.width;
         this._notificationBin.x = 0;
-        this._notificationBin.width = primary.width;
+        this._notificationBin.width = monitor.width;
         this._summaryBin.x = 0;
-        this._summaryBin.width = primary.width;
+        this._summaryBin.width = monitor.width;
 
         if (this._pointerBarrier)
             global.destroy_pointer_barrier(this._pointerBarrier);
         this._pointerBarrier =
-            global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height,
-                                          primary.x + primary.width, primary.y + primary.height,
+            global.create_pointer_barrier(monitor.x + monitor.width, monitor.y + monitor.height - this.actor.height,
+                                          monitor.x + monitor.width, monitor.y + monitor.height,
                                           4 /* BarrierNegativeX */);
 
 
@@ -1867,18 +1867,18 @@ MessageTray.prototype = {
     },
 
     _showTray: function() {
-        let primary = Main.layoutManager.primaryMonitor;
+        let monitor = Main.layoutManager.bottomMonitor;
         this._tween(this.actor, '_trayState', State.SHOWN,
-                    { y: primary.y + primary.height - this.actor.height,
+                    { y: monitor.y + monitor.height - this.actor.height,
                       time: ANIMATION_TIME,
                       transition: 'easeOutQuad'
                     });
     },
 
     _hideTray: function() {
-        let primary = Main.layoutManager.primaryMonitor;
+        let monitor = Main.layoutManager.bottomMonitor;
         this._tween(this.actor, '_trayState', State.HIDDEN,
-                    { y: primary.y + primary.height - 1,
+                    { y: monitor.y + monitor.height - 1,
                       time: ANIMATION_TIME,
                       transition: 'easeOutQuad'
                     });